#ifndef HEAD_H
#define HEAD_H

#include <QDebug>
#include <QTimer>
#include <QMap>
#include <QFile>
#include <QDir>


#include <QThread>

#define _THIS_NET_MAC_ 12

//收到上位机发送的对应摄像头枚举
enum CameraMethod
{
    MidWaveInfrared = 0x01,  //中波红外
    LongWaveInfrared = 0x02,    //长波红外
    aerial = 0x03,       //空中
    airMidWaveInfraed = 0x04   //空中红外
};

//UDP接收消息的方式
enum UdpBindWay
{
    UNICAST = 0x01,     //单播
    MULTICAST = 0x02,   //组播
    BROADCAST = 0x03    //广播
};

//对应config.ini中config0 - configN的顺序, 用于存储区分
enum SaveIndex {
    _air = 0,  //空中图像
    _airMidWaveifd = 1,  //空中中波红外
    _groundMidWaveifd = 2,  //地面中波红外
    _groundLongWaveifd = 3, //地面长波红外

    _QXMsg = 4,     //黑体_气象站_能见度仪信息
    _TYFSMsg = 5,   //太阳辐射计信息
    _GNSSMsg = 6,   //GNSS信息

    _airRanging = 7, //空中测距机
    _grounpRanging = 8, //地面测距机
    _groundTurntable = 9,  //地面转台俯仰
};

#pragma pack(push, 1)  // 开始1字节对齐


typedef struct _MSGINI{
    QString _QxIP = "";
    quint16 _QxPort = 0;
    QString _TYFSIP = "";
    quint16 _TYFSPort = 0;
    QString _GNSSIP = "";
    quint16 _GNSSPort = 0;

    // 赋值运算符重载
    _MSGINI& operator=(const _MSGINI& other) {
        if (this != &other) {
            _QxIP = other._QxIP;
            _QxPort = other._QxPort;
            _TYFSIP = other._TYFSIP;
            _TYFSPort = other._TYFSPort;
            _GNSSIP = other._GNSSIP;
            _GNSSPort = other._GNSSPort;
        }
        return *this;
    }
}MSGINI;


typedef struct SaveDataTail
{
    unsigned char _tail[4] = {0x0A, 0x0D, 0xA5, 0x5A};
}SaveDataTail;

typedef struct _VIDEO_SAVE_CONFIG
{
    QString resourcesName;      //视频资源名
    QString srcIP;              //源ip
    quint16 bindPort;           //监听端口
    QString bindIP;             //监听IP
    QString bindNetWorkCard;    //监听网卡
    UdpBindWay bindWay;         //监听方式 1：单播  2：组播  3：广播
    QString des;                //保存前缀
    SaveIndex saveMethod;    //视频流来源的格式

    _VIDEO_SAVE_CONFIG() {
        resourcesName = "default";
        srcIP = "127.0.0.1";
        bindPort = 1234;
        bindIP = "127.0.0.1";
        bindNetWorkCard = "eth0";
        bindWay = UNICAST;
        des = "des_";
        saveMethod = _air;
    }
    _VIDEO_SAVE_CONFIG(QString name, QString ip_out, quint16 port_out, QString bindIP_out, QString bindNetWorkCard_out,
                       UdpBindWay bindWay_out, QString des_out, SaveIndex saveMethod_out) {
        resourcesName = name;
        srcIP = ip_out;
        bindPort = port_out;
        bindIP = bindIP_out;
        bindNetWorkCard = bindNetWorkCard_out;
        bindWay = bindWay_out;
        des = des_out;
        saveMethod = saveMethod_out;
    }

    // 赋值运算符重载
    _VIDEO_SAVE_CONFIG& operator=(const _VIDEO_SAVE_CONFIG& other) {
        if (this != &other) {
            resourcesName = other.resourcesName;
            srcIP = other.srcIP;
            bindPort = other.bindPort;
            bindIP = other.bindIP;
            bindNetWorkCard = other.bindNetWorkCard;
            bindWay = other.bindWay;
            des = other.des;
            saveMethod = other.saveMethod;
        }
        return *this;
    }
}VIDEO_SAVE_CONFIG;

//上位机ip信息保存结构体
typedef struct _HostMachine
{
    _HostMachine() {}
    QString listenIP; //监听IP
    quint16 listport; //监听port
    QString destIP;   //目标IP
    quint16 destPort; //目标port
}HostMachine;

#pragma pack(pop)   // 恢复默认对齐

#endif // HEAD_H
